#!/usr/bin/env python
from ssummolib import get_accessions , get_combined_accessions, Options
import cPickle as pickle
import sys

class Counter:
    def __init__(self, options):
        self.options = options
    def count(self):
        print 'File name'.ljust( 25 ) , '#_sequences'.rjust( 25 )
        total = 0
        for in_file in self.options['-in']:
            print in_file.ljust( 25 ),
            with file( in_file ,'rb' ) as handle:
                results = pickle.load( handle )
            n = len( get_accessions( results , accessions = [] ) )
            print str(n).rjust( 25 )
            total += n
        print 'TOTAL'.ljust(25) , str(total).rjust(25)
class MyOptions( Options ):
    def __init__(self,args ):
        self.multiargs = ['-in']
        self.singleargs = []
        self.options = { '-in' : [] }
        self.parseArgs( args )

if __name__ == '__main__':
    options = MyOptions(sys.argv[1:])
    count = Counter( options )
    count.count()
